<? if(!defined('UC_ROOT')) exit('Access Denied');?>
<? include $this->gettpl('header_client');?>
<? include $this->gettpl('pm_nav');?>

<script type="text/javascript">
function switchfirendls() {
	if(document.getElementById('friendls').style.display == '') {
		document.getElementById('friendls').style.display = 'none';
		document.getElementById('pmcontent').className = 'pmcontent noside';
	} else {
		document.getElementById('friendls').style.display = '';
		document.getElementById('pmcontent').className = 'pmcontent';
	}
}
</script>

<div class="ucinfo">
	<? if($do == 'savebox' && $messagepreview) { ?><h1><?=$subject?><? } ?>
	<? if($pmid && $do == 'forward') { ?>
		<h1><span><button onclick="location.href='index.php?m=pm_client&a=view&pmid=<?=$pmid?>&folder=inbox&<?=$extra?>'">返回</button></span></h1>
	<? } elseif($pmid && $do == 'savebox') { ?>
		<span><button onclick="location.href='index.php?m=pm_client&a=ls&folder=savebox&<?=$extraret?>'">返回</button></span>
	<? } ?>

	<? if($do == 'savebox' && $messagepreview) { ?>
		</h1>
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="newpm">
		<tbody>
			<tr<? if($pm['new']) { ?> class="onset"<? } ?>>
				<td class="sel"></td>
				<td class="ava">预览短消息</td>
				<td class="title"><?=$messagepreview?></td>
				<td class="ava"><img src="avatar.php?uid=<?=$user['uid']?>&size=small" /></td>
			</tr>
		</tbody>
		</table>
	<? } ?>

	<form method="post" id="postpmform" name="postpmform" action="index.php?m=pm_client&a=send<? if($pmid && $do == 'savebox') { ?>&pmid=<?=$pmid?><? } ?>&<?=$extra?>">
	<input type="hidden" name="formhash" value="<?=FORMHASH?>">
	<input type="hidden" name="saveoutbox" value="0">
	<input type="hidden" name="related" value="<?=$related?>">
	<? if($sendpmseccode) { ?><input type="hidden" name="seccodehidden" value="<?=$seccodeinit?>" /><? } ?>
	<div class="pmcontent<? if(!$friends) { ?> noside<? } ?>" id="pmcontent">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="newpm">
		<tbody>
			<tr>
				<td class="sel"></td>
				<th>消息标题:</th>
				<td><input class="ucinput" type="text" name="subject" size="65" maxlength="75" value="<?=$subject?>" />
				<? if($friends) { ?>
					<a class="moreuser" href="###" onclick="switchfirendls()" title="打开/关闭 好友列表">close</a>
				<? } ?>
				</td>
			</tr>
			<tr>
				<td class="sel"></td>
				<th>收件人:</th>
				<td>
				<input class="ucinput" type="text" name="msgto" size="65" value="<?=$touser?>" />
				</td>
			</tr>
			<tr>
				<td class="sel"></td>
				<th>消息内容:</th>
				<td>
				<? include $this->gettpl('pm_editorbar');?>
				<textarea class="listarea" id="pm_textarea" rows="15" cols="10" style="height: 210px" name="message" onKeyDown="ctlent(event)"><?=$message?></textarea>
				</td>
			</tr>
			<? if($sendpmseccode) { ?>
			<tr>
				<td class="sel"></td>
				<th>验证码:</th>
				<td>
					<label><input type="text" name="seccode" value="" size="5" /> <img width="70" height="21" src="admin.php?m=seccode&seccodeauth=<?=$seccodeinit?>&<? echo rand();?>" /></label>
				</td>
			</tr>
			<? } ?>
		</tbody>

		<tfoot>
			<tr>
				<td class="sel"></td>
				<th></th>
				<td>
				<button name="pmsubmit" type="submit" class="pmsubmit" onclick="this.form.saveoutbox.value = 0">发送</button>
				<? if($a == 'savebox') { ?><button name="pmsubmit" type="button" onclick="location='index.php?m=pm_client&a=delete&pmid=<?=$pmid?>&folder=savebox&<?=$extra?>'">删除</button><? } ?>
				<button name="pmsavesubmit" type="button" onclick="this.form.saveoutbox.value = 1;this.form.submit()">保存</button>
				</td>
			</tr>
		</tfoot>
	</table>
	</div>
	<? if($friends) { ?>
	<div class="pmside" id="friendls">
		<h3><input type="checkbox" name="chkall" onclick="checkall(this.form, 'friend')" value="<?=$pm['pmid']?>" /> 好友</h3>
		<ul>
		<? foreach((array)$friends as $friend) {?>
			<li><input type="checkbox" name="friend[]" value="<?=$friend['friendid']?>"> <?=$friend['username']?></li>
		<? } ?>
		</ul>
	</div>
	<? } ?>
	</form>
</div>

<? include $this->gettpl('footer_client');?>